﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Student Calendar</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
        /*code_begin*/
        $(document).ready(function () {
            var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 1 });
            initSpread(spread);
        });

        function initSpread(spread) {
            $.ajax({
                url: "studentcalendar_json.txt",
                datatype: "text",
                beforeSend: function(xhr) {
                },
                success: function (data) {
                        try {
                            var sd = JSON.parse(data);
                            if (sd.length > 0) {
                                if (!spread) {
                                    return;
                                }

                                spread.isPaintSuspended(true);
                                spread.fromJSON(sd[0]);
                                spread.newTabVisible = false;

                                var sheetCount = spread.getSheetCount();
                                for (var i = 0; i < sheetCount; i++) {
                                    var sheet = spread.getSheet(i);
                                    sheet.setColumnVisible(0, false, GcSpread.Sheets.SheetArea.rowHeader);
                                    sheet.setRowVisible(0, false, GcSpread.Sheets.SheetArea.colHeader);
                                    sheet.setGridlineOptions({ showHorizontalGridline: false, showVerticalGridline: false });
                                    var baseRow = 3, baseCol = 2;
                                    for (var r = 0; r < 6; r++) {
                                        for (var c = 0; c < 7; c++) {
                                            sheet.setFormatter(baseRow + r, baseCol + c, new GcSpread.Sheets.GeneralFormatter("d"), GcSpread.Sheets.SheetArea.viewport);
                                        }
                                    }
                                }

                                spread.isPaintSuspended(false);
                            }
                        } catch (ex) {
                        }
                },
                error: function (ex) {
                    alert(ex);
                }
            });
        }
        /*code_end*/
    </script>
</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width:100%; height:620px;border: 1px solid gray;"></div>
    </div>
</body>
</html>